const fs = window.require('fs').promises

const fileHelper = {
  readFile: (path) => {
    return fs.readFile(path, { encoding: 'utf8'})
  },
  writeFile: (path, content) => {
    return fs.writeFile(path, content, { encoding: 'utf8'})
  },
  renameFile: (path, newPath) => {
    return fs.rename(path, newPath)
  },
  deleteFile: (path) => {
    return fs.unlink(path)
  }
}

export default fileHelper

// const fs = require('fs')
// const path = require('path')

// const fileHelper = {
//   readFile: (path, cb) => {
//     fs.readFile(path, { encoding: 'utf8' }, (err, data) => {
//       if(!err){
//         cb(data)
//       }
//     })
//   },
//   writeFile: (path, content, cb) => {
//     fs.writeFile(path, content, { encoding: 'utf8' }, (err) => {
//       if(!err){
//         cb()
//       }
//     })
//   }
// }

// const testPath = path.join(__dirname, 'helper.js')
// fileHelper.readFile(testPath, (data) => {
//   console.log(data)
// })



